package com.sjgtw.cloud.web.equipmentCheck.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import com.sjgtw.cloud.web.equipmentCheck.domain.EquipmentCheck;
import com.sjgtw.cloud.web.equipmentCheck.service.IEquipmentCheckService;
import io.swagger.annotations.Api;
import com.sjgtw.cloud.common.core.utils.poi.ExcelUtil;
import com.sjgtw.cloud.common.core.web.controller.BaseController;
import com.sjgtw.cloud.common.core.web.domain.AjaxResult;
import com.sjgtw.cloud.common.core.web.page.TableDataInfo;

/**
 * 防洪设备检查Controller
 * 
 * @author lvyoufang
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/equipmentCheck")
@Api(tags = "2.2、应急设施-防洪设备检查")
public class EquipmentCheckController extends BaseController
{
    @Autowired
    private IEquipmentCheckService equipmentCheckService;

    /**
     * 查询防洪设备检查列表
     */
    @ApiOperation(value = "查询防洪设备检查列表")
    @GetMapping("/list")
    public TableDataInfo list(EquipmentCheck equipmentCheck)
    {
        startPage();
        List<EquipmentCheck> list = equipmentCheckService.selectEquipmentCheckList(equipmentCheck);
        return getDataTable(list);
    }

    /**
     * 导出防洪设备检查列表
     */
    @ApiOperation(value = "导出防洪设备检查列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipmentCheck equipmentCheck)
    {
        List<EquipmentCheck> list = equipmentCheckService.selectEquipmentCheckList(equipmentCheck);
        ExcelUtil<EquipmentCheck> util = new ExcelUtil<EquipmentCheck>(EquipmentCheck.class);
	    try {
		    util.exportExcel(response, list, "防洪设备检查数据");
	    } catch (IOException e) {
		    e.printStackTrace();
	    }
    }

    /**
     * 获取防洪设备检查详细信息
     */
    @ApiOperation(value = "获取防洪设备检查详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(equipmentCheckService.selectEquipmentCheckById(id));
    }

    /**
     * 新增防洪设备检查
     */
    @ApiOperation(value = "新增防洪设备检查")
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentCheck equipmentCheck)
    {
        return toAjax(equipmentCheckService.insertEquipmentCheck(equipmentCheck));
    }

    /**
     * 修改防洪设备检查
     */
    @ApiOperation(value = "修改防洪设备检查")
    @PutMapping
    public AjaxResult edit(@RequestBody EquipmentCheck equipmentCheck)
    {
        return toAjax(equipmentCheckService.updateEquipmentCheck(equipmentCheck));
    }

    /**
     * 删除防洪设备检查
     */
    @ApiOperation(value = "删除防洪设备检查")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(equipmentCheckService.deleteEquipmentCheckByIds(ids));
    }

    /**
     * 删除防洪设备检查
     */
    @ApiOperation(value = "删除防洪设备检查")
    @GetMapping("/delete/{id}")
    public AjaxResult deleteById(@PathVariable Long id)
    {
        return toAjax(equipmentCheckService.deleteEquipmentCheckById(id));
    }

}
